package cloud.xiguapi.ubas.controller;

import cloud.xiguapi.ubas.common.ApiResult;
import cloud.xiguapi.ubas.common.Pager;
import cloud.xiguapi.ubas.entity.ChannelMarketing;
import cloud.xiguapi.ubas.service.IMarketingService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 大大大西西瓜皮🍉
 * date: 2021-5-20 下午 04:45
 * desc:
 */
@RestController
@RequestMapping("/channel-marketing")
public class ChannelMarketingController {

    @Resource(name = "channelMarketingService")
    private IMarketingService<ChannelMarketing> channelMarketingService;

    @GetMapping("/analysis")
    public ApiResult<Object> analysis() {
        return channelMarketingService.analysis();
    }

    @GetMapping("/select/{current}/{size}")
    public ApiResult<Pager<ChannelMarketing>> selectPage(@PathVariable long current, @PathVariable long size) {
        if (current <= 0) {
            current = 1;
        }
        if (size <= 0) {
            size = 10;
        }
        return channelMarketingService.selectPage(current, size);
    }
}
